package com.seria.test01;

public class Humanoid implements java.io.Serializable {
	protected int noOfHeads;
	private static int totalHeads;

	public Humanoid() {
		this(1);
		System.out.println("Human's default constructor is invoked");
	}

	public Humanoid(int noOfHeads) {
		if (noOfHeads > 10)
			throw new Error("Be serious. More than 10 heads?!");
		this.noOfHeads = noOfHeads;
		synchronized (Humanoid.class) {
			totalHeads += noOfHeads;
		}
	}

	public int getHeadCount() {
		return totalHeads;
	}
}